Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modern packaging + ruff + numpy 2 compat #187

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

raphaelvallat
Copy link
Owner

@raphaelvallat raphaelvallat commented Dec 20, 2024

This PR implements the following changes:

  • Switch to modern packaging: everything is defined in the pyproject.toml. Source files are moved to the src/yasa/ folder, while tests are now in the tests folder at the root directory
  • Switch to using Ruff instead of Black + Flake8
  • Ensure compatibility with numpy >2.x

@remrama
Copy link
Collaborator

remrama commented Dec 20, 2024

Sweet! Thanks @raphaelvallat, I was planning to include this in next release as well. I'll check it on my end in the next hour with a review.

@remrama remrama self-requested a review December 20, 2024 15:33
Copy link
Collaborator

@remrama remrama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raphaelvallat sorry I know this is still WIP and you didn't request this, but I just glossed it over and here are small/quick things to add. All comments are trivially addressable and probably would've come up anyways during your checks so I hope they speed things up for you.

As far as Ruff formatting goes I think it will only end up changing 3 files when you run it. Currently the workflow breaks but it should pass once you run the formatter.

pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
.github/workflows/python_tests.yml Show resolved Hide resolved
README.rst Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.

Project coverage is 77.20%. Comparing base (0e4689d) to head (319a0fe).

Files with missing lines Patch % Lines
src/yasa/evaluation.py 0.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (0e4689d) and HEAD (319a0fe). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (0e4689d) HEAD (319a0fe)
3 1
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #187      +/-   ##
==========================================
- Coverage   83.90%   77.20%   -6.70%     
==========================================
  Files          24       13      -11     
  Lines        3498     2628     -870     
  Branches        0      321     +321     
==========================================
- Hits         2935     2029     -906     
  Misses        563      563              
- Partials        0       36      +36     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@raphaelvallat
Copy link
Owner Author

Note that there's a CI failure on Python 3.12 because of a depreceated import of pkg_resources in the lspopt dependency

https://github.com/hbldh/lspopt/blob/6867aa95e9ced721defc07027e8231973ecb4f26/lspopt/data/__init__.py#L11

See mu-editor/mu#2485

src/yasa/detection.py Outdated Show resolved Hide resolved
src/yasa/evaluation.py Outdated Show resolved Hide resolved
@raphaelvallat
Copy link
Owner Author

Ready for review @remrama ! There's one CI failure because of coverage that I think we can ignore

@raphaelvallat raphaelvallat self-assigned this Dec 21, 2024
@raphaelvallat raphaelvallat changed the title [WIP] Modern packaging + ruff (NPY201) Modern packaging + ruff (NPY201) Dec 21, 2024
@raphaelvallat raphaelvallat changed the title Modern packaging + ruff (NPY201) Modern packaging + ruff + numpy 2 compat Dec 21, 2024
Copy link
Collaborator

@remrama remrama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @raphaelvallat! Thanks a lot for doing this, I think it makes it easier to work on subsequent PRs.

@@ -11,8 +11,8 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest] # macos-latest
python-version: ["3.9", "3.10", "3.11"]
platform: [ubuntu-latest, windows-latest] # macos-latest disabled because of lightgbm fail
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I did not realize that YASA fails on mac... too bad, I wonder if there is a way around this in the future. Do you have any ideas on that? Just asking here but of course nothing to address for this PR 👍

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem solved — tests are now passing on macos as well 🚀

@@ -26,7 +26,7 @@ classifiers = [
"Programming Language :: Python :: 3.12",
]
dynamic = ["version"]
requires-python = ">=3.8"
requires-python = ">=3.9"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the failure on python v3.12, should we change this to >=3.9, <3.12?

I think we should go forward as-is without >3.11 support, but given that Python currently supports versions up to 3.13, I would like to not fall that far behind. Maybe I can add a PR on lspopt about this? We could be patient about a fix and then come up with an alternate plan if need be.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep support for 3.12. I'll investigate the lspopt issue now

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem solved here as well. Just needed to add setuptools to the dependencies.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this still creates a DeprecationWarning in the tests. We should update lspopt at some point:

=============================== warnings summary ===============================
../../../../../opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/site-packages/lspopt/data/__init__.py:11
  /opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/site-packages/lspopt/data/__init__.py:11: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    from pkg_resources import resource_filename

push_pypi.md Outdated Show resolved Hide resolved
@raphaelvallat
Copy link
Owner Author

PR ready to be merged as soon as #127 is merged!

@raphaelvallat raphaelvallat linked an issue Dec 22, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch to modern python packaging
3 participants